package demo.practice.bit;

public class P693 {

    public static void main(String[] args) {

        System.out.println();

//        P693 p693= new P693();
//        p693.hasAlternatingBits(5);
//        System.out.println(Integer.toBinaryString(15));
    }

    public boolean hasAlternatingBits(int n) {
        n ^= (n >> 1);
        return (n & (n + 1)) == 0;
    }

   /* public boolean hasAlternatingBits(int n) {

        //return ((n<<1)+1) ^
        if(n==Integer.MAX_VALUE)
            return false;

        int by= (n&1)==0? ((n>>1)) ^ n : (n<<1) ^ n;

        while (by>0){
           if( ( by& 1 )==0)
               return false;
           by>>=1;
        }
        return true;
    }*/
}
